/*    */ package dm.jdbc.driver;
/*    */ 
/*    */ import dm.jdbc.dataConvertion.CnvtInfo;
/*    */ import dm.jdbc.dataConvertion.Convertion;
/*    */ import dm.jdbc.dbaccess.DBError;
/*    */ import dm.jdbc.dbaccess.DmMsgSend;
/*    */ import dm.sql.DmdbDateTime;
/*    */ import dm.sql.DmdbTime;
/*    */ import java.sql.Date;
/*    */ import java.sql.SQLException;
/*    */ import java.sql.Timestamp;
/*    */ 
/*    */ public class DmTimestampBinder
/*    */   extends DmBinder
/*    */ {
/*    */   public DmTimestampBinder(DmdbPreparedStatement_bs pstmt)
/*    */   {
/* 18 */     super(pstmt);
/*    */   }
/*    */   
/*    */   void init() {
/* 22 */     this.recDType = 16;
/* 23 */     this.recPrec = 8;
/* 24 */     this.recScale = 0;
/*    */   }
/*    */   
/*    */   public int bindData(DmMsgSend msg, int irow, int icol, boolean forBatch) throws SQLException
/*    */   {
/* 29 */     Timestamp x = ((Timestamp[])this.pstmt.m_paramObjects[icol])[irow];
/* 30 */     CnvtInfo cnvtInfo = this.pstmt.connection.getCnvtInfo();
/* 31 */     String serverEncoding = cnvtInfo.getServerEncoding();
/* 32 */     short dbTz = cnvtInfo.getDbTz();
/* 33 */     short ltz = cnvtInfo.getTimeZone();
/*    */     
/* 35 */     byte[] ret = toDbBytes(x, this.destDType, this.destPrec, this.srcScale, 
/* 36 */       serverEncoding, ltz, dbTz);
/*    */     
/* 38 */     return msg.appendBytesWithLen2(ret, 0, ret.length);
/*    */   }
/*    */   
/*    */   public static byte[] toDbBytes(Timestamp x, int destDType, int destPrec, int srcScale, String serverEncoding, short ltz, short dbTz)
/*    */     throws SQLException
/*    */   {
/* 44 */     byte[] ret = null;
/* 45 */     DmdbDateTime dt = null;
/* 46 */     switch (destDType) {
/*    */     case 14: 
/* 48 */       dt = new DmdbDateTime(new Date(x.getTime()).toString(), srcScale, 
/* 49 */         0);
/* 50 */       ret = Convertion.DateToByteArray(dt);
/* 51 */       break;
/*    */     case 15: 
/* 53 */       String time = x.toString();
/* 54 */       int timeind = time.indexOf(" ");
/* 55 */       time = time.substring(timeind + 1, time.length());
/* 56 */       DmdbTime t = new DmdbTime(time, srcScale);
/* 57 */       ret = Convertion.TimeToByteArray(t);
/* 58 */       break;
/*    */     case 16: 
/* 60 */       dt = new DmdbDateTime(x.toString(), srcScale, 
/* 61 */         2);
/* 62 */       ret = Convertion.TimeStampToByteArray(dt, destDType, srcScale, 
/* 63 */         dbTz, ltz);
/* 64 */       break;
/*    */     case 0: 
/*    */     case 1: 
/* 67 */       ret = Convertion.String_char_2CType(String.valueOf(x), destPrec, 
/* 68 */         destDType, serverEncoding);
/* 69 */       break;
/*    */     case 2: 
/*    */     case 19: 
/* 72 */       ret = Convertion.String_varchar_2CType(String.valueOf(x), destPrec, 
/* 73 */         destDType, serverEncoding);
/* 74 */       break;
/*    */     case 22: 
/* 76 */       String str = x.toString();
/* 77 */       int ind = str.indexOf(" ");
/* 78 */       str = str.substring(ind + 1, str.length());
/* 79 */       ret = Convertion.String_javaObj_2CType(str, destDType, srcScale, 
/* 80 */         destPrec, ltz);
/* 81 */       break;
/*    */     case 20: 
/*    */     case 21: 
/*    */     case 23: 
/* 85 */       ret = Convertion.String_javaObj_2CType(x.toString(), destDType, 
/* 86 */         srcScale, destPrec, ltz);
/* 87 */       break;
/*    */     case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 17: case 18: default: 
/* 89 */       DBError.throwSQLException(6007);
/*    */     }
/* 91 */     return ret;
/*    */   }
/*    */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\dm\jdbc\driver\DmTimestampBinder.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */